/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* IBust - IBus with Traditional interface
 * Copyright(c) 2013 Daniel Sun
 * Copyright (c) 2009, Google Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#if !defined (__IBUST_H_INSIDE__) && !defined (IBUST_COMPILATION)
#error "Only <ibust.h> can be included directly"
#endif

/**
 * SECTION: ibustpanelservice
 * @short_description: Panel service back-end.
 * @stability: Stable
 *
 * An IBustPanelService is a base class for UI services.
 * Developers can "extend" this class for panel UI development.
 */
#ifndef __IBUST_PANEL_SERVICE_H_
#define __IBUST_PANEL_SERVICE_H_

#include "ibustlookuptable.h"
#include "ibustservice.h"
#include "ibustproplist.h"

/*
 * Type macros.
 */

/* define GOBJECT macros */
#define IBUST_TYPE_PANEL_SERVICE                \
    (ibust_panel_service_get_type ())
#define IBUST_PANEL_SERVICE(obj)                        \
    (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUST_TYPE_PANEL_SERVICE, IBustPanelService))
#define IBUST_PANEL_SERVICE_CLASS(klass)        \
    (G_TYPE_CHECK_CLASS_CAST ((klass), IBUST_TYPE_PANEL_SERVICE, IBustPanelServiceClass))
#define IBUST_IS_PANEL_SERVICE(obj)                     \
    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUST_TYPE_PANEL_SERVICE))
#define IBUST_IS_PANEL_SERVICE_CLASS(klass)             \
    (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUST_TYPE_PANEL_SERVICE))
#define IBUST_PANEL_SERVICE_GET_CLASS(obj)      \
    (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUST_TYPE_PANEL_SERVICE, IBustPanelServiceClass))

G_BEGIN_DECLS

typedef struct _IBustPanelService IBustPanelService;
typedef struct _IBustPanelServiceClass IBustPanelServiceClass;

/**
 * IBustPanelService:
 *
 * An opaque data type representing an IBustPanelService.
 */
struct _IBustPanelService {
    IBustService parent;
    /* instance members */
};

struct _IBustPanelServiceClass {
    IBustServiceClass parent;

    /* class members */
    void     (* focus_in)                  (IBustPanelService       *panel,
                                            const gchar            *input_context_path);
    void     (* focus_out)                 (IBustPanelService       *panel,
                                            const gchar            *input_context_path);
    void     (* register_properties)       (IBustPanelService       *panel,
                                            IBustPropList           *prop_list);
    void     (* set_cursor_location)       (IBustPanelService       *panel,
                                            gint                    x,
                                            gint                    y,
                                            gint                    w,
                                            gint                    h);
    void     (* update_auxiliary_text)     (IBustPanelService       *panel,
                                            IBustText               *text,
                                            gboolean                visible);
    void     (* update_lookup_table)       (IBustPanelService       *panel,
                                            IBustLookupTable        *lookup_table,
                                            gboolean                visible);
    void     (* update_preedit_text)       (IBustPanelService       *panel,
                                            IBustText              *text,
                                            guint                  cursor_pos,
                                            gboolean               visible);
    void     (* update_property)           (IBustPanelService       *panel,
                                            IBustProperty           *prop);
    void     (* cursor_down_lookup_table)  (IBustPanelService       *panel);
    void     (* cursor_up_lookup_table)    (IBustPanelService       *panel);
    void     (* hide_auxiliary_text)       (IBustPanelService       *panel);
    void     (* hide_language_bar)         (IBustPanelService       *panel);
    void     (* hide_lookup_table)         (IBustPanelService       *panel);
    void     (* hide_preedit_text)         (IBustPanelService       *panel);
    void     (* page_down_lookup_table)    (IBustPanelService       *panel);
    void     (* page_up_lookup_table)      (IBustPanelService       *panel);
    void     (* reset)                     (IBustPanelService       *panel);
    void     (* show_auxiliary_text)       (IBustPanelService       *panel);
    void     (* show_language_bar)         (IBustPanelService       *panel);
    void     (* show_lookup_table)         (IBustPanelService       *panel);
    void     (* show_preedit_text)         (IBustPanelService       *panel);
    void     (* start_setup)               (IBustPanelService       *panel);
    void     (* state_changed)             (IBustPanelService       *panel);

    /*< private >*/
    /* padding */
    gpointer pdummy[8];  // We can add 8 pointers without breaking the ABI.
};

GType            ibust_panel_service_get_type  (void);

/**
 * ibust_panel_service_new:
 * @connection: An GDBusConnection.
 * @returns: A newly allocated IBustPanelService.
 *
 * New an IBustPanelService from an GDBusConnection.
 */
IBustPanelService *ibust_panel_service_new (GDBusConnection    *connection);

/**
 * ibust_panel_service_candidate_clicked
 * @panel: An IBustPanelService
 * @index: Index in the Lookup table
 * @button: GdkEventButton::button (1: left button, etc.)
 * @state: GdkEventButton::state (key modifier flags)
 *
 * Notify that a candidate is clicked
 * by sending a "CandidateClicked" to IBust service.
 */
void ibust_panel_service_candidate_clicked (IBustPanelService *panel,
                                           guint             index,
                                           guint             button,
                                           guint             state);

/**
 * ibust_panel_service_cursor_down
 * @panel: An IBustPanelService
 *
 * Notify that the cursor is down
 * by sending a "CursorDown" to IBust service.
 */
void ibust_panel_service_cursor_down       (IBustPanelService *panel);

/**
 * ibust_panel_service_cursor_up
 * @panel: An IBustPanelService
 *
 * Notify that the cursor is up
 * by sending a "CursorUp" to IBust service.
 */
void ibust_panel_service_cursor_up         (IBustPanelService *panel);

/**
 * ibust_panel_service_page_down
 * @panel: An IBustPanelService
 *
 * Notify that the page is down
 * by sending a "PageDown" to IBust service.
 */
void ibust_panel_service_page_down         (IBustPanelService *panel);

/**
 * ibust_panel_service_page_up
 * @panel: An IBustPanelService
 *
 * Notify that the page is up
 * by sending a "PageUp" to IBust service.
 */
void ibust_panel_service_page_up           (IBustPanelService *panel);

/**
 * ibust_panel_service_property_activate
 * @panel: An IBustPanelService
 * @prop_name: A property name
 * @prop_state: State of the property
 *
 * Notify that a property is active
 * by sending a "PropertyActivate" message to IBust service.
 */
void ibust_panel_service_property_activate (IBustPanelService *panel,
                                           const gchar      *prop_name,
                                           guint             prop_state);
/**
 * ibust_panel_service_property_show
 * @panel: An IBustPanelService
 * @prop_name: A property name
 *
 * Notify that a property is shown
 * by sending a "ValueChanged" message to IBust service.
 */
void ibust_panel_service_property_show     (IBustPanelService *panel,
                                           const gchar      *prop_name);

/**
 * ibust_panel_service_property_hide
 * @panel: An IBustPanelService
 * @prop_name: A property name
 *
 * Notify that a property is hidden
 * by sending a "ValueChanged" message to IBust service.
 */
void ibust_panel_service_property_hide     (IBustPanelService *panel,
                                           const gchar      *prop_name);


G_END_DECLS
#endif
